import {Dimensions, View} from 'react-native';
import Video from 'react-native-video';
import ColorButton from 'react-native-cdy-baseui/components/ColorButton';
import {
  responsiveNumber,
  responsiveNumberByHeight,
} from 'react-native-responsive-number/src/index';
import ModalViewUtil from 'react-native-cdy-baseui/utils/ModalViewUtil';
import {useState} from 'react';
export function VideoPlayer(props) {
  const [paused, setPaused] = useState(false);
  return (
    <View
      style={{
        width: Dimensions.get('screen').width * 0.7,
        height: Dimensions.get('screen').height * 0.6,
        borderRadius: 20,
        backgroundColor: 'white',
        alignItems: 'center',
      }}>
      <Video
        source={{uri: props.nodePath}} // Can be a URL or a local file.
        ref={ref => {
          this.player = ref;
        }} // Store reference
        // onBuffer={this.onBuffer} // Callback when remote video is buffering
        // onError={this.videoError} // Callback when video cannot be loaded
        style={{width: '100%', height: '100%'}}
        resizeMode={'contain'}
        onVideoLoad={() => {
          // console.log("----");
        }}
        controls={true}
      />
      <ColorButton
        backgroundColor="#6FC5C3"
        height={responsiveNumber(10)}
        containerStyle={{
          paddingHorizontal: 30,
          marginTop: responsiveNumber(10),
        }}
        fontSize={responsiveNumber(8)}
        onPress={() => ModalViewUtil.dismissView()}
        color={'white'}>
        关闭
      </ColorButton>
    </View>
  );
}
